1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular to a method and apparatus for processing data. Still more particularly, the present invention relates to a computer implemented method, apparatus, and computer usable program code for call stack sampling in a data processing system.
2. Description of the Related Art
In writing code, runtime analysis of the code is often performed as part of an optimization process. Runtime analysis is used to understand the behavior of components or modules within the code using data collected during the execution of the code. The analysis of the data collected may provide insight to various potential misbehaviors in the code. For example, an understanding of execution paths, code coverage, memory utilization, memory errors and memory leaks in native applications, performance bottlenecks, and threading problems are examples of aspects that may be identified through analyzing the code during execution.
The performance characteristics of code may be identified using a software performance analysis tool. The identification of the different characteristics may be based on a trace facility of a trace system. A trace tool may be used using various techniques to provide information, such as execution flows as well as other aspects of an executing program. A trace may contain data about the execution of code. For example, a trace may contain trace records about events generated during the execution of the code. A trace also may include information, such as, a process identifier, a thread identifier, and a program counter. Information in the trace may vary depending on the particular profile or analysis that is to be performed. A record is a unit of information relating to an event that is detected during the execution of the code.
Attempting to obtain an unbiased time based sample call stack from a virtual machine, such as a Java™ virtual machine, on an operating system may be a difficult task. Java™ is a trademark of Sun Microsystems, Inc. Many approaches are presently used for obtaining call stack information. These approaches include obtaining an application timer tick or instrumenting code and sampling the instrumented values. These types of techniques, however, in a symmetric multi-processor (SMP) system have a drawback of requiring additional instrumentation in the code or possibly allowing the thread whose call stack is to be sampled to migrate to a different processor during the sampling process.
More specifically, in time profiling, a timer interrupt may cause a process to obtain an instruction address for a thread that is being executed at the time of the interrupt. With environments such as Java™ or other object oriented environments, an ability is present to obtain call stack information that includes the internal state of the virtual machine. The call stack may be requested from a virtual machine to obtain information for analysis. One problem that occurs with this type of process is that when the call stack is requested, the thread that has been interrupted may migrate to a different processor. Migration of the thread from one processor to another processor may result in reports that are biased. On a symmetric multiprocessor (SMP) system, it is advantageous to obtain samples from each processor in order to collect information about the state of the machine on all processors. Sampling threads may be bound to each processor as part of a profiling algorithm implemented by a profiler. For example, if an interrupt is generated on processor 1, interrupting thread 1, and an attempt to obtain the call stack on thread 1 causes the thread 1 to migrate to processor 2, then an interrupt on processor 2 may also interrupt thread 1. This type of migration may cause samples for thread 1 to be counted more often than desired, which is referred to as overcounting.
Thus, it would be advantageous to have an improved computer implemented method, apparatus, and computer usable program code for obtaining call stack information on a multi-processor system.